<!DOCTYPE HTML><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $title ?></title>
<? require("lib.php"); ?>
<link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
</head>
<body>
<div class="content-box">
    <div class="content-box-header">
        <h3><? echo $title ?></h3>
        <div class="clear"></div>
    </div>
    <div class="content-box-content">
<?
  switch ($do) {
    case "add": add(); break;
	case "update": update($info); break;
	case "delete": delete($id); break;
    default:	show_info($info);
  }

function show_boxes($result){ 
		global $page, $pages, $baseurl, $cate, $cateid, $s, $gee, $url, $sales_order_detail, $product, $user, $lang, $country, $code_array, $arrcurrency, $customer, $filter, $h, $checkin, $checkout,$weekago, $arr_payment, $arr_shipment, $arr_province, $arr_city, $arr_county;
		$str='<table width="99%" class="mlist"><tr>'; // 搜索
		$str.='<td><form action="'.$url.'.php" method="get">'.ROOT_ORDER_TIME.': 
		<input name="checkin" class="checkin gs" value="'.$checkin.'" /> &nbsp; - &nbsp; <input name="checkout" class="checkout gs" value="'.$checkout.'" /> &nbsp; <input type="submit" class="button_blue" value=" '.ROOT_SEARCH.' " /></form></td>';
		$str.='<td align="right"><a href="report_sales.php?checkin='.$checkin.'&checkout='.$checkout.'&export=1" target="_blank" class="blue">'.ROOT_EXPORT_CSV.'</a></td>';
		$str.='</tr></table>';
		$str.= '<table width="99%" cellspacing="0" cellpadding="3" class="mlist" id="picbox"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_ORDER_REFERENCE_NUMBER.'</strong></td><td><strong>'.ROOT_EMAIL.'</strong></td><td><strong>'.ROOT_PRODUCT.'</strong></td>
		<td><strong>'.ROOT_AMOUNT.'</strong></td>';
		//<td><strong>'.ROOT_RECEIVER_ADDRESS.'</strong></td>
		//<td><strong>'.ROOT_PHONE.'</strong></td>
		//<td><strong>'.ROOT_RECEIVER.'</strong></td>
		//<td><strong>'.ROOT_CUSTOMER_REMARKS.'</strong></td>
		$str.= '<td><strong>'.ROOT_PAYMENT_METHOD.'</strong></td>';
		//$str.= '<td><strong>'.ROOT_PAID_TIME.'</strong></td>';
		//<td><strong>'.ROOT_PAYER.'</strong></td>
		$str.= '<td><strong>'.ROOT_SHIPPING_METHOD.'</strong></td>';
		$str.= '<td><strong>'.ROOT_SHIPPING_FEE.'</strong></td>';
		//<td><strong>'.ROOT_ORDER_DISPATCH_TIME.'</strong></td>
		//<td><strong>'.ROOT_TRACKING_NUMBER.'</strong></td>
		//<td><strong>'.ROOT_HANDLING_REMARKS.'</strong></td>
		$str.= '<td><strong>'.ROOT_ORDER_STATUS.'</strong></td><td><strong>'.ROOT_ORDER_TIME.'</strong></td>
		</tr>';
		$status=$code_array['order_status'];
		$count=1;
    	foreach($result as $row)
		{
			// order detail 订单详情
			$tem=$sales_order_detail->get_rows(64,'sales_order_id',$row['id']);
			$iteming='';
			foreach( $tem as $r ){
				$tempro=$product->get_row($r['product_id']);
				$sku=$tempro['sku'];
				$iteming.=$sku.' * '.$r['quantity'];
				$iteming.='<br />';
			}
			// 状态
			$cstatus=$status[$row['order_status']]['name_'.$lang];
			$customer_id=$row['customer_id'];
			if($customer_id==0) $customer_name=ROOT_GUEST_ACCOUNT;
			else {
				$customer_array=$customer->get_row($customer_id);
				$customer_email=$customer_array['email'];
			}
			//$country_name=$country->get_name($row['country'],$lang);
			$currency_code=$arrcurrency[$row['currency_id']]['code'];
			// shipment 寄送方式
			$tem_shipment=$arr_shipment[$row['shipment_method_id']]['name_'.$lang];

			// payment 支付方式
			if($row['payment_method_id']==0) $tem_payment='-';
			else $tem_payment=$arr_payment[$row['payment_method_id']]['name_'.$lang];
			// // province 省
			// $tem_province=$arr_province[$row['province']]['name_'.$lang];
			// // city 市
			// $tem_city=$arr_city[$row['city']]['name_'.$lang];
			// // county 区
			// $tem_county=$arr_county[$row['county']]['name_'.$lang];
			// $address=$tem_province.'/'.$tem_city.'/'.$tem_county.','.$row['address'];

			$id=$row['id'];
      		$str.='<tr><td>'.$id.'.</td><td>'.decode($row['ref_no']).'</td><td>'.$customer_email.'</td><td>'.$iteming.'</td><td>'.$currency_code.' '.$row['total_price'].'</td>';
      		//<td>'.$address.'</td>
      		//<td>'.$row['mobile'].'</td>
      		//<td>'.$row['contact_name'].'</td>
      		//<td>'.$row['customer_remark'].'</td>
      		$str.='<td>'.$tem_payment.'</td>';
      		//<td>'.$row['paid_time'].'</td>
      		//<td>'.$row['payer'].'</td>
      		$str.='<td>'.$tem_shipment.'</td>';
      		$str.='<td>'.$row['shipment_cost'].'</td>';
      		//$str.='<td>'.$row['shipped_time'].'</td>';
      		//<td>'.$row['shipment_tracking_no'].'</td>
      		//<td>'.$row['operator_remark'].'</td>';
			$str.='<td>'.$cstatus.'</td><td>'.$row['created_time'].'</td></tr>';              
			$count++;
		}
		$str.= "</table>";
		if($count==1) $str.= "<br>".ROOT_NO_DATA."!";
		echo $str;
		$temurl=$url.'.php?checkin='.$checkin.'&checkout='.$checkout.'&page=';
		echo echo_page_raw($page, $pages, $temurl);
     } ?>
 <br class="clear" />
	</div>
         <br class="clear" />
</div>
<script type="text/javascript">
$(function(){
	var temlang='<?echo $lang=="sc"?"ch":"en"?>';
 $('.checkin').datetimepicker({
  format:'Y-m-d',lang:temlang,
  onShow:function( ct ){
   this.setOptions({
    maxDate:'<?=$weekago?>'
   })
  },
  timepicker:false
 });
 $('.checkout').datetimepicker({
  format:'Y-m-d',lang:temlang,
  onShow:function( ct ){
   this.setOptions({
    //minDate:$('.checkin').val()?$('.checkin').val():'',
    maxDate:'<?=date("Y-m-d")?>'
   })
  },
  timepicker:false
 });
});
</script>
</body>
</html>